﻿using Avalon.Core.MVC.StateBags;
using Avalon.Core.Data;
using System;
using System.Linq;

namespace Avalon.Core.MVC.Actions
{
    //public sealed class GetEntityCountAction<TModel> where TModel : class, IEntity, new()
    //{
    //    private readonly IEntityBag<TModel> mBag;

    //    public GetEntityCountAction(IEntityBag<TModel> pBag)
    //    {
    //        mBag = pBag;
    //    }

    //    public int Execute()
    //    {
    //        try
    //        {
    //            IRepository<TModel> lRepository = RepositoryConfig.Initialize<TModel>();
    //            return lRepository.Get().Count();
    //        }
    //        catch (Exception lEx)
    //        {
    //            mBag.Error = new Exception(string.Format("Failed to get the entity count: {0}", typeof(TModel).Name), lEx);
    //        }
    //        return -1;
    //    }
    //}
}
